#pragma once

#include <deque>
#include <algorithm>
using namespace std;

template<class T>
class CTExplorerViewList
{
public:
	typedef deque<CMDIChildWnd*> ExplorerViewList;

protected:
	CTExplorerViewList() { }

public:
	static CTExplorerViewList* Instance()
	{
		static CTExplorerViewList _explorer;
		return &_explorer;
	}

public:
	static void AddExplorerView(CMDIChildWnd* pMDIChildWnd)
	{
		ExplorerViewList::iterator ite = std::find(m_listExplorerView.begin(), m_listExplorerView.end(), pMDIChildWnd);
		if(ite == m_listExplorerView.end())
		{
			m_listExplorerView.push_front(pMDIChildWnd);
		}

		m_pCurrExplorerView = pMDIChildWnd;
	}

	static void DelExplorerView(CMDIChildWnd* pMDIChildWnd)
	{
		ExplorerViewList::iterator ite = find(m_listExplorerView.begin(), m_listExplorerView.end(), pMDIChildWnd);
		if(ite != m_listExplorerView.end())
			m_listExplorerView.erase(ite);
	}

	CMDIChildWnd* GetExplorerView()
	{
		return m_pCurrExplorerView;
	}

	const ExplorerViewList& GetExplorerViewList()
	{
		return m_listExplorerView;
	}

private:
	static CMDIChildWnd*	m_pCurrExplorerView;
	static ExplorerViewList m_listExplorerView;
};

template<class T>
deque<CMDIChildWnd*> CTExplorerViewList<T>::m_listExplorerView;

template<class T>
CMDIChildWnd* CTExplorerViewList<T>::m_pCurrExplorerView = NULL;

typedef CTExplorerViewList<int> CExplorerViewList;